#导包
from unit02.Base import Base
from selenium import webdriver
import openpyxl,pytest

@pytest.fixture(scope='function')
def driver():
    #启动浏览器
    driver=webdriver.Firefox()
    driver.maximize_window()
    yield driver
    driver.quit()

def test_baidu_ceshi(driver):
    work=openpyxl.load_workbook('812月考百度表格.xlsx')
    excel=work['Sheet1']
    base=Base(driver)

    #循环导入
    for row in excel.iter_rows(min_row=2,values_only=True):
        #从第二行开始执行
        action=row[2]
        #存储值
        params={}

        if action=='goto':
            params['url']=row[4]


        elif action in['send_keys','click','text']:
            if action=='text':
                params['loc']=[row[3],row[4]]

        if action=='text':
            assert '198' in row[5]

        method=getattr(base,str(action))
        method(**params)

